package com.yakuj3.android.comptadroid.DAO;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;

public class DatabaseHandler extends SQLiteOpenHelper {

	public static final String OPERATION_KEY = "id";
	public static final String OPERATION_MONTH = "mois";
	public static final String OPERATION_LIBELE = "libele";
	public static final String OPERATION_MONTANT = "montant";
	     
	public static final String OPERATION_TABLE_NAME = "operation";
	public static final String OPERATION_TABLE_CREATE =
			"CREATE TABLE " + OPERATION_TABLE_NAME + " (" +
			OPERATION_KEY + " INTEGER PRIMARY KEY AUTOINCREMENT, " +
			OPERATION_MONTH + " TEXT, " +
			OPERATION_LIBELE + " TEXT, " +
			OPERATION_MONTANT + " REAL);";
	public static final String OPERATION_DROP_TABLE = "DROP TABLE IF EXISTS " + OPERATION_TABLE_NAME + ";";;
	 
	public DatabaseHandler(Context context, String name, CursorFactory factory, int version) {
		super(context, name, factory, version);
	}
	 
	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(OPERATION_TABLE_CREATE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		// TODO Auto-generated method stub
		db.execSQL(OPERATION_DROP_TABLE);
		onCreate(db);
	}
	
}
